
let timeFilter = (format, setDate) => {
    // 补0操作
    function PrefixInteger(num, n) {
        return (Array(n).join(0) + num).slice(-n);
    }
    function type(type) {
        return Object.prototype.toString.call(type).replace(/\[object (.*)\]/, '$1')
    }
    // 得到时间
    let date = setDate || new Date()
    if (type(date) != 'Date') {
        date = new Date(date)
    }
    let dateObj = {}
    dateObj.year = date.getFullYear();
    dateObj.month = PrefixInteger(date.getMonth() + 1, 2);
    dateObj.date = PrefixInteger(date.getDate(), 2);
    dateObj.dayIndex = date.getDay();
    dateObj.day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[date.getDay()];
    dateObj.hour = PrefixInteger(date.getHours(), 2);
    dateObj.minute = PrefixInteger(date.getMinutes(), 2);
    dateObj.second = PrefixInteger(date.getSeconds(), 2);
    dateObj.value = format.replace('YYYY', dateObj.year).replace('MM', dateObj.month).replace('DD', dateObj.date).replace('hh', dateObj.hour).replace('mm', dateObj.minute).replace('ss', dateObj.second)
    return dateObj
}


